package com.jerei.web.utils;

import org.springframework.web.context.ContextLoaderListener;
import org.springframework.web.context.WebApplicationContext;

import javax.servlet.ServletContextEvent;

/**
 * Created by sunfeihu on 2016/11/25.
 */
public class JrContextLoaderListener extends ContextLoaderListener {

    public JrContextLoaderListener() {
    }

    public JrContextLoaderListener(WebApplicationContext context) {
        super(context);
    }


    /**
     * Initialize the root web application context.
     */
    @Override
    public void contextInitialized(ServletContextEvent event) {
        //初始化Spring配置
        super.contextInitialized(event);
        //初始化插件
        UtilsPluginManager.init(event.getServletContext().getRealPath("/admin/plugins/"));
    }

    @Override
    public void contextDestroyed(ServletContextEvent event) {
        super.contextDestroyed(event);
        UtilsPluginManager.get().stopPlugins();
    }
}
